from typing import *


class Solution:
    def maximumLength(self, nums: List[int]) -> int:

        a0, b0, a1, b1 = 0, 0, 0, 0  #  奇，偶
        for num in nums:
            if num & 1 == 1:  # 奇数
                a0 += 1
                a1 = max(a1, b1 + 1)
            else:  # 偶数
                b0 += 1
                b1 = max(b1, a1 + 1)
        return max(a0, b0, a1, b1)


s = Solution()
print(s.maximumLength([1, 3]))
print(s.maximumLength([1, 2, 1, 1, 2, 1, 2]))
